PHP: parse 您所在的位置:网站首页 parse software PHP: parse

PHP: parse

2024-01-19 12:44| 来源: 网络整理| 查看: 265

parse_str

(PHP 4, PHP 5, PHP 7, PHP 8)

parse_str — Parses the string into variables

Description parse_str(string $string, array &$result): void

Parses string as if it were the query string passed via a URL and sets variables in the current scope (or in the array if result is provided).

Parameters

string

The input string.

result

If the second parameter result is present, variables are stored in this variable as array elements instead.

Warning

Using this function without the result parameter is highly DISCOURAGED and DEPRECATED as of PHP 7.2. As of PHP 8.0.0, the result parameter is mandatory.

Return Values

No value is returned.

Changelog

Version Description 8.0.0 result is no longer optional. 7.2.0 Usage of parse_str() without a second parameter now emits an E_DEPRECATED notice. Examples

Example #1 Using parse_str()

Because variables in PHP can't have dots and spaces in their names, those are converted to underscores. Same applies to naming of respective key names in case of using this function with result parameter.

Example #2 parse_str() name mangling

Notes

Note:

All variables created (or values returned into array if second parameter is set) are already urldecode()d.

Note:

To get the current QUERY_STRING, you may use the variable $_SERVER['QUERY_STRING']. Also, you may want to read the section on variables from external sources.

See Also

parse_url() - Parse a URL and return its components pathinfo() - Returns information about a file path http_build_query() - Generate URL-encoded query string urldecode() - Decodes URL-encoded string


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有